/*******************************************************************************
 * Copyright 2011 See AUTHORS file.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/

package org.xxforest.game.core.scenes.scene2d.events.type;

import org.xxforest.game.core.scenes.scene2d.XXNode;
import org.xxforest.game.core.scenes.scene2d.XXScreen;
import org.xxforest.game.core.scenes.scene2d.events.XXEvent;
import org.xxforest.game.core.scenes.scene2d.events.XXEventType;

import com.badlogic.gdx.utils.Pools;

public class XXInputEvent implements XXEvent {
	private XXScreen screen ;
	private XXEventType type;
	private float screenX, screenY;
	private int pointer, button, keyCode, scrollAmount;
	private char character;
	private XXNode relatedSpirit , target;

	public float getScreenX () {
		return screenX;
	}

	public void setScreenX (float screenX) {
		this.screenX = screenX;
	}

	public float getScreenY () {
		return screenY;
	}

	public void setScreenY (float screenY) {
		this.screenY = screenY;
	}

	public XXEventType getType () {
		return type;
	}

	public void setType (XXEventType type) {
		this.type = type;
	}

	public int getPointer () {
		return pointer;
	}

	public void setPointer (int pointer) {
		this.pointer = pointer;
	}

	public int getButton () {
		return button;
	}

	public void setButton (int button) {
		this.button = button;
	}

	public int getKeyCode () {
		return keyCode;
	}
	
	public boolean isKeyCode(int keyCode){
		return this.keyCode == keyCode ;
	}

	public void setKeyCode (int keyCode) {
		this.keyCode = keyCode;
	}

	public char getCharacter () {
		return character;
	}

	public void setCharacter (char character) {
		this.character = character;
	}

	public int getScrollAmount () {
		return scrollAmount;
	}

	public void setScrollAmount (int scrollAmount) {
		this.scrollAmount = scrollAmount;
	}

	public XXNode getRelatedSpirit () {
		return relatedSpirit;
	}

	public void setRelatedSpirit (XXNode relatedSpirit) {
		this.relatedSpirit = relatedSpirit;
	}

	public String toString () {
		return type.toString();
	}

	@Override
	public void dispose() {
		relatedSpirit = null;
		button = -1;
		screen = null ;
		Pools.free(this);
	}

	@Override
	public XXEventType getEventType() {
		return type;
	}

	public static XXInputEvent create() {
		return Pools.obtain(XXInputEvent.class);
	}

	public void setScreen(XXScreen screen) {
		this.screen = screen ;
	}
	
	public XXScreen getScreen(){
		return this.screen ;
	}

	public void setTarget(XXNode target) {
		this.target = target ;
	}

	public XXNode getTarget() {
		return target;
	}
	
	
}
